package day18;

import java.util.Calendar;

public class CalendarDemo {

	public static void main(String[] args) {
		// setDemo();
		addDemo();
	}
    
	public static void addDemo() {
		String[] months = { "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月",
				"九月", "十月", "十一月", "十二月", };
		Calendar calendar = Calendar.getInstance();
		calendar.add(Calendar.YEAR, 3);
		calendar.add(Calendar.MONTH, -1);
		calendar.add(Calendar.DAY_OF_MONTH, 10);
		System.out.println(calendar.get(Calendar.YEAR) + "年");
		System.out.println(months[calendar.get(Calendar.MONTH)]);
		System.out.println(calendar.get(Calendar.DAY_OF_MONTH) + "日");
	}

	public static void setDemo() {
		Calendar calendar = Calendar.getInstance();
		calendar.set(2015, 3, 15);
		calendar.set(Calendar.YEAR, 2017);
		String[] months = { "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月",
				"九月", "十月", "十一月", "十二月", };
		System.out.println(calendar.get(Calendar.YEAR) + "年");
		System.out.println(months[calendar.get(Calendar.MONTH)]);
		System.out.println(calendar.get(Calendar.DAY_OF_MONTH) + "日");
	}

	public static void baseDemo() {
		Calendar calendar = Calendar.getInstance();
		String[] months = { "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月",
				"九月", "十月", "十一月", "十二月", };
		System.out.println(calendar.get(Calendar.YEAR) + "年");
		System.out.println(months[calendar.get(Calendar.MONTH)]);
		System.out.println(calendar.get(Calendar.DAY_OF_MONTH) + "日");
	}
}
